<!-- 考生试卷列表 -->
<template>
  <div class="parper">
    <div class="parper-title">
      总计：<span style="color: var(--main-color)">{{ total }}人</span>
    </div>
     <div class="new_nav flex">
      <div :class="rating_status == 1 ? 'active' : ''" @click="toType(1)">
        待评分
      </div>
      <div :class="rating_status == 2 ? 'active' : ''" @click="toType(2)">
        已评分
      </div>
    </div>
    <el-table :data="list" height="67vh" style="width: 95%">
      <el-table-column prop="index" label="序号" width="150"></el-table-column>
      <el-table-column prop="subject_name" label="科目名称" width="400">
      </el-table-column>
      <el-table-column prop="subject_level_name" label="考试级别" width="250">
      </el-table-column>
      <el-table-column prop="status_name" label="状态" width="350">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            @click="handleEdit(scope.$index, scope.row)"
            class="btn-item"
            plain
            type="danger"
            >{{scope.row.rating_status==1?'立即评分':'查看详情'}}</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div class="page flex align center">
      <div
        class="prev-box flex align center"
        @click="next(0)"
        :style="{ transform: index == 0 ? 'scale(0.9)' : '' }"
      >
        <i class="el-icon-arrow-left font"></i>
      </div>
      <div class="count">
        <span>{{ totalPages == 1 ? totalPages : page }}/</span>{{ totalPages }}
      </div>
      <div
        class="prev-box flex align center"
        @click="next(1)"
        :style="{ transform: index == 1 ? 'scale(0.9)' : '' }"
      >
        <i class="el-icon-arrow-right font"></i>
      </div>
    </div>
  </div>
</template>

<script>
import { getSubjectRecordList,examinerList } from "@/api/apiData";
import { mapMutations } from "vuex";
import Mixin from "@/mixin/index.js";
export default {
  name: "parper",
  components: {},
  mixins:[Mixin],
  data() {
    return {
      // activeName: "first",
      page: 0,
      totalPages: 1,
      offset: 7,
      list: [],
      total: 0,
      index: -1,
      idx: 1,
      rating_status:1
    };
  },
  computed: {},
  methods: {
    ...mapMutations(["saveImage"]),
    // handleClick(tab, event) {
    //   console.log(tab, event);
    // },
    toType(n) {
      this.rating_status = n;
      this.page = 0;
      this.totalPages = 1;
      this.list = [];
      this.getList();
    },
    // 跳转改卷
    handleEdit(index, data) {
      let parpams = {
        product_id: data.product_id,
        rating_status: data.rating_status,
      };
      this.saveImage(data.avatar);
      let name;
      // switch (data.check_type) {
      //   case 1: //钢琴
      //     name = "examParper";
      //     break;
      //   case 2: //听力
      //     name = "listenerParper";
      //     parpams.exam_video = data.exam_video;
      //     break;
      //   case 3: //歌唱
      //     name = "singerResult";
      //     break;
      // }
      this.$router.push({
        name: 'videoResult',
        query: parpams,
      });
    },
    // 获取试卷
    getList() {
      const that = this;
      let { page, offset, totalPages, list, idx,rating_status } = that;
      let obj = {
        exam_room_id: that.$route.query.id,
        page: idx == 0 ? page - 1 : page + 1,
        offset: offset,
        rating_status,rating_status
      };
      if (idx == 0) {
        --page;
      }
      if (totalPages > page) {
        examinerList(obj).then((res) => {
          // //(res);
          if (res.code == 1) {
            let arr = res.data.list;
            arr.forEach((item, index) => {
              item.index = index + 1;
              item.name = that.$route.query.name;
              item.status_name = item.rating_status==2?'已评分':'待评分'
            });
            that.list = arr;
            that.page = idx == 0 ? page : page + 1;
            that.totalPages = Math.ceil(res.data.total / offset);
            that.total = res.data.total;
          } else {
          }
        });
      } else {
        //  全部加载加载完毕
        this.$message({
          type: "warning",
          message: "已经是最后一页了~",
        });
      }
    },
    // 翻页
    next(val) {
      const that = this;
      const { page } = that;
      that.index = val;
      that.idx = val;
      setTimeout(() => {
        that.index = -1;
      }, 100);

      if (val == 0) {
        if (page == 1) {
          this.$message({
            type: "warning",
            message: "已经是第一页了~",
          });
          return;
        }
      }

      that.getList();
    },
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.getList();
    });
  },
};
</script>
<style lang='less' scoped>
  .new_nav {
    background: white;
    padding: 20px 50px;
    margin-top: 2px;
    div {
      cursor: pointer;
      margin-right: 60px;
      font-size: 28px;
      color: gray;
      padding-bottom: 10px;
      border-bottom: solid 3px transparent;
    }
    .active {
      color: #0096ff;
      border-bottom: solid 3px;
    }
  }
.parper {
  padding: 16px 0;
  background: #f6f9fc;
  width: 100%;
  height: 90vh;
  overflow: hidden;
  .parper-title {
    font-size: 28px;
    font-weight: bold;
    color: #1d1b1b;
    padding: 6px 45px;
    background: #fff;
  }
  .el-table {
    margin: 25px auto 0;
  }
  //   表格
  /deep/ .has-gutter .cell {
    color: @main-color;
    font-size: 30px;
    overflow: visible;
    line-height: 1.5;
    background: transparent;
  }
  /deep/.cell {
    text-align: center;
    color: #111;
    font-weight: bold;
    font-size: 28px;
    overflow: visible;
    line-height: 1.5;
  }
  /deep/ .has-gutter .is-leaf {
    background: #f6f9fc !important;
    border: 0;
  }
  /deep/.has-gutter .gutter {
    background: #f6f9fc;
  }
  // /deep/.el-table--scrollable-y .el-table__body-wrapper {
  //   overflow: hidden;
  // }
  // /deep/.el-table--scrollable-y .el-table__body-wrapper::-webkit-scrollbar {
  //   display: none;
  // }
  .btn-item {
    font-size: 26px;
  }
  // page
  .page {
    width: 100%;
    margin-top: 5vh;
    text-align: center;
    .prev-box {
      width: 42px;
      height: 42px;
      border-radius: 50%;
      border: 1px solid @main-color;
      cursor: pointer;
      .font {
        font-size: 30px;
        color: @main-color;
        font-weight: bold;
      }
    }
    .count {
      cursor: default;
      width: 30%;
      font-size: 32px;
      color: @main-color;
      span {
        font-size: 42px;
      }
    }
  }
}
</style>